#ifndef ALTMATH_BINARYOPERATOR_H
#define ALTMATH_BINARYOPERATOR_H

#include "expressiontreenode.h"
#include <QFlags>

namespace AltMath {
     /*! Represents the +,-,*,/, and ^ binary arithmetic operators. The operator's left and right children are its operands. This class assumes that the left and right children exist. */
     class BinaryOperator : public ExpressionTreeNode {
     public:
          /*! Types of binary operations. */
          enum Operations {
               Addition,
               Subtraction,
               Multiplication,
               Division,
               Exponentiation,
               Modulo
          };
          Q_DECLARE_FLAGS(Operation, Operations);

          /*! Evaluates the operation. If either operand is undefined, the result is undefined. */
          Result evaluate() const;

          /*! This operator's operation. */
          Operation operation() const;

          /*! Returns the precedence of a given operation.
               @param The operation to check. */
          static int precedence(Operation op);

          /*! Sets this operator's operation.
               @param op This operator's operation. */
          void setOperation(Operation op);

     private:
          /*! This operator's operation. */
          Operation m_operation;
     };
     Q_DECLARE_OPERATORS_FOR_FLAGS(BinaryOperator::Operation)
}

#endif
